package com.sixth.volunteerservicesystem.Controller.ExamController.frontExam;

import com.sixth.volunteerservicesystem.Dao.QuestionRepository;
import com.sixth.volunteerservicesystem.domain.Subjects;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Steve Jobs
 * @create 2020-12-18 18:04
 */

@RestController
public class QuestionController {

    @Autowired
    QuestionRepository questionRepository;

    @GetMapping("/question/{id}")
    public Subjects getQuestion(@PathVariable("id") Integer id){
        Subjects subjects = questionRepository.findById(id).get();
        return subjects;
    }

    @GetMapping("/question")
    public Subjects insertQuestion(Subjects questions){
        Subjects save = questionRepository.save(questions);
        return save;
    }

//    @GetMapping("/update")
//    public Subjects update(Subjects question){
//
//    }

//    public List<Subjects> findRandomQuestionById(){
//        Subjects ranQuestion = null;
//        Map<Integer,Subjects> map = new HashMap<>();
//
//        int n = 0;
//        for(int i = 0;i < 20;i++){
//            n = (int) (Math.random() * 3 + 1);
//           ranQuestion = questionRepository.findById(n).get();
//            map.put(i,ranQuestion);
//        }
//
//
//        return ranQuestions;
//    }

}
